package com.jk.controller;

import com.jk.service.LogService;
import com.jk.vo.UserLoginLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;

/**
 * @author 李卓
 * @create 2017-12-24 17:08
 **/

public class LogRegController {

    @Autowired
    private LogService logService;

    @ResponseBody
    public String insertLoginLog(byte[] log){
       /*Object o = byteToObj(log);
        UserLoginLog userLog= (UserLoginLog) o;*/
        int i = logService.insertLog(null);
        System.out.println(i);
      UserLoginLog u=new UserLoginLog();
        //logService.insertLog(u);
        return null;
    }


    /*字节流转换对象*/
    public  Object byteToObj(byte[] byt){
        Object obj = null;
        try {
            // bytearray to object
            ByteArrayInputStream bi = new ByteArrayInputStream(byt);
            ObjectInputStream oi = new ObjectInputStream(bi);
            obj = oi.readObject();
            bi.close();
            oi.close();
        } catch (Exception e) {
            System.out.println("translation" + e.getMessage());
            e.printStackTrace();
        }
        return obj;
    }

}
